package com.TechM.get;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.TechM.get.Dao.JobStatusRepository;
import com.TechM.get.Domain.JobStatus;
import com.TechM.get.Service.QueryDataService;

@Component
public class Jobs {
	@Autowired
	QueryDataService queryDataService;
	@Autowired
	JobStatusRepository jobStatusRepository;
	//只要status为“on”，执行完一次save后，间隔5秒再次执行
	@Scheduled(fixedDelay = 5 * 1000)
	public void fixedDelayJob() {
		List<JobStatus> list = jobStatusRepository.findAll();
		if (list != null && list.size() != 0) {
			String flag = list.get(0).getStatus();
			if (flag.equals("on")) {
				queryDataService.saveData();
			}
		}
	}
}
